import pymysql
class DB_Tool:
    def setup(self):
        conn = pymysql.connect(host="211.103.136.244", port=7061, user="student", password="iHRM_student_2022",
                               database="ihrm", charset="utf8")
        return conn
    def select(self,sql):
        curs = None
        conn = None
        try:
            conn = self.setup()
            curs = conn.cursor()
            curs.execute(sql)
            return curs.fetchone()
        except Exception as err:
            print(err)
        finally:
            curs.close()
            conn.close()

    def iud(self,sql):
        conn =None
        cursor = None
        try:
            conn = self.setup()
            cursor = conn.cursor()
            ert = cursor.execute(sql)
            print(ert)
            conn.commit()
        except Exception as err:
            conn.rollback()
            print(err)
        finally:
            cursor.close()
            conn.close()
